package org.CGLibProxy;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import javax.xml.ws.spi.Invoker;
import java.lang.reflect.Method;

/**
 * Created by chinalin on 2017/3/17.
 */
public class TestMain {
    public static void main(String[] args) {
        HelloImpl hello = CGLibProxy.getInstance().getProxy(HelloImpl.class) ;
        hello.say("jack");
        hello.say1(false);
        hello.say2(25);

        HelloImpl hello1 = (HelloImpl) Enhancer.create(HelloImpl.class, new MethodInterceptor() {
            public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
                System.out.println("方法前");
                Object result = proxy.invokeSuper(obj,args) ;
                System.out.println("方法后");
                return null;
            }
        });

        hello1.say("ltd");
    }
}
